<template>

	<view class="loding" v-if="loding">
		<loading></loading>
	</view>
	<view v-else>
		<ul class="timeline-wrapper">
			<li class="timeline-item" v-for="t in timelineList" :key="t.id">
				<view class="timeline-box">
					<view class="out-circle">
						<view class="in-circle"></view>
					</view>
					<view class="long-line"></view>
				</view>
				<view class="timeline-content">
					<view class="timeline-date">{{t.date}}</view>
					<view class="timeline-title">{{ t.company}}</view>
					<view class="timeline-position">{{t.position}}</view>
					<view class="timeline-desc">{{ t.content}}</view>
				</view>
			</li>
		</ul>
	</view>
</template>

<script>
	import loading from '../../components/loading.vue'
	export default {
		data() {
			return {
				timelineList: [],
				loding: true
			}
		},
		components:{
			loading
		},
		methods: {
			onLoad() {
				uniCloud.callFunction({
					name: "work-experience",
					data: {},
					success: (res) => {
						this.loding = false
						console.log('2', this.loding)
						console.log(res.result.data);
						for (let i = 0; i < res.result.data.length; i++) {
							this.timelineList.push(res.result.data[i])
						}
						console.log(this.timelineList);
					},
					fail: (err) => {
						console.log(err);
					}

				})
			},
			get() {
				uni.createSelectorQuery().in(this).select('.timeline-content').boundingClientRect(result => {
					if (result) {
						console.log(result.height)
					} else {
						this.get();
					}
				}).exec();
			},
		}
	}
</script>

<style scoped lang="scss">
	.loding {
		display: flex;
		justify-content: center;
		align-items: center;
		height: 100vh;
	}

	ul.timeline-wrapper {
		list-style: none;
		margin: 0;
		padding: 40rpx;
	}

	/* 时间线 */
	.timeline-item {
		position: relative;

		.timeline-box {
			text-align: center;
			position: absolute;

			.out-circle {
				width: 40rpx;
				height: 40rpx;
				background: rgba(14, 116, 218, 0.1);
				box-shadow: 0 8rpx 24rpx 0 rgba(0, 0, 0, 0.1);
				border-radius: 50%;
				display: flex;
				align-items: center;

				.in-circle {
					width: 21rpx;
					height: 21rpx;
					margin: 0 auto;
					background: rgba(14, 116, 218, 1);
					border-radius: 50%;
					box-shadow: 0px 4px 12px 0px rgba(0, 0, 0, 0.1);
				}
			}

			.long-line {
				width: 2px;
				height: 70px;
				background: rgba(14, 116, 218, 1);
				box-shadow: 0px 4px 12px 0px rgba(0, 0, 0, 0.1);
				opacity: 0.1;
				margin-left: 8px;
			}
		}

		.timeline-content {
			box-sizing: border-box;
			margin-left: 50rpx;
			height: auto;
			background-color: #d2e8ff;
			border-radius: 20rpx;
			padding: 20rpx 16rpx 20rpx 40rpx;
			text-align: left;
			margin-bottom: 30rpx;

			.timeline-date {
				font-size: 28rpx;
				color: #757575;
				font-weight: bold;
				margin-bottom: 16rpx;
			}

			.timeline-title {
				font-size: 28rpx;
				word-break: break-all;
				margin-bottom: 16rpx;
				color: #414141;
				font-weight: bold;

				/*display: inline;*/
			}

			.timeline-position {
				font-size: 26rpx;
				margin-bottom: 16rpx;
				color: #757575;
				font-weight: bold;
			}

			.timeline-desc {
				font-size: 26rpx;
				line-height: 38rpx;
				color: #999999;
			}
		}

	}


	.timeline-item:last-of-type .timeline-content {
		margin-bottom: 0;
	}
</style>
